package LC;

/**
 * @ClassName LC35
 * @Description: TODO
 * @Author hl
 * @Date 2021/4/18
 * @Version V1.0
 **/
public class LC35 {
    public static int searchInsert(int[] nums, int target) {
        int n=nums.length;
        int left=0;
        int right=n-1;
        while(left<=right){
            int mid=((right-left)>>1)+left;
            if(nums[mid]<target){

                left=mid+1;
            }else{
                n=mid;
                right=mid-1;
            }
        }
        return n;
    }

    public static void main(String[] args) {
        int []nums={1,3,5,6};
        System.out.println(searchInsert(nums,7));

    }

}
